{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2304cde5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "#思路,一篮子币种,5个品种,在区间涨落, 每周期后换仓\n",
    "#验证2个问题: 1. 币种越多是不是风险越低,收益越好   2.每周期是都卖掉还是只卖掉高于某个阈值的币?\n",
    "sum=0.0\n",
    "s=0.0\n",
    "ini=50.0 #初始资金,每种币\n",
    "nu=5 #币品种数\n",
    "for pe in range(0,20):   # 运行周期数,比如选币后3天卖出为1周期\n",
    "    for i in range(0,nu):   #币的品种数\n",
    "        pv=random.uniform(0.89,1.41)  #随机涨落区间89%-141%\n",
    "        s=pv*ini\n",
    "        sum=sum+s\n",
    "        print(round(s,2),round(pv,2))\n",
    "    print('---',pe,'',round(sum,2))\n",
    "    ini=sum/nu #平均分配下次每种投资额\n",
    "    sum=0.0"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
